from rest_framework import serializers

from goods.models import SPU


class SPUGoodsSerialzier(serializers.ModelSerializer):
    '''
    SPU序列化器
    '''
    # 一级分类id
    category1_id = serializers.IntegerField()
    # 二级分类id
    category2_id = serializers.IntegerField()
    # 三级级分类id
    category3_id = serializers.IntegerField()
    # 关联的品牌id
    brand_id = serializers.IntegerField()
    # 关联的品牌，名称
    brand = serializers.StringRelatedField(read_only=True)



class Meta:
    #指定根据那个模型类生成序列化器字段
    model = SPU
    #指定那些字段生成
    exclude = ('category1', 'category2', 'category3')
